/**
 * Created by songnaibing on 23/11/17.
 */
$(document).ready(function(){
    $(".popup .close").click(function(){
        $(".popup").hide();
    });

    //弹窗打开和关闭效果
    $("#verification").click(function () {
        $(".verification").show();
    });
    //$(".close-v").click(function () {
    //    $(".verification").hide();
    //});

    // 切换页签
    var $li = $(".tab li");
    var $cont= $(".tab-content");
    $li.click(function(){
        var index = $(this).index();
        $li.removeClass();
        $(this).addClass("current");
        $cont.hide();
        $cont.eq(index).show();
    });


    //清空输入框效果
    $(".input-box .clear-btn").bind({
        click: function () {
            $(this).addClass("hidden");
            $(this).siblings("input").val("");
        }
    });
    $(".input-box input").bind({
        keyup: function () {
            var val = $(this).val();
            if (val != "") {
                $(this).siblings("i").removeClass("hidden");
            }
            else {
                $(this).siblings("i").addClass("hidden");
            }
        }
    });

    //密码明文和加密模式切换效果
    $(".input-box .eye").click(function () {
        if ($("input[name='password']").attr("type") == "password") {
            $("input[name='password']").attr("type", "text");
            $(this).addClass("on").removeClass("off")
        }
        else {
            $("input[name='password']").attr("type", "password");
            $(this).addClass("off").removeClass("on")
        }
    });


})

// 验证码倒计时功能
var requireds = 0;
$(function () {
    var btnFinish = $(".btn-finish");
    $(".blurChange").bind({
        keyup: function () {
            var pr = $(this).siblings(".prompt");
            var val = $(this).val();
            var required = $(this).attr("alt");
            if (val != "") {
                pr.hide();
                if (required) {
                    if (required == "0") {
                        requireds++;
                        $(this).attr("alt", "1");
                        if (requireds == 2) {
                            btnFinish.removeClass("btn-finish-disable");
                        }
                    }
                }
            }
            else {
                if (required) {
                    if (required == "1") {
                        requireds--;
                        $(this).attr("alt", "0");
                        if (requireds != 2) {
                            btnFinish.addClass("btn-finish-disable");
                        }
                    }
                }
            }
        },
        blur: function () {
            var pr = $(this).siblings(".prompt");
            var val = $(this).val();
            if (val == "") {
                pr.show();
            }
        }
    });
    $(".blurChange").each(function () {
//            var pr =$(this).siblings(".prompt");
        var val = $(this).val("");
//            if(val != ""){
//                pr.hide();
//            }
    });
    //$("body").delegate(".verify-btn", "click", function () {
        //reduction();
    //});

});
var totalSecond = 119;

function reduction() {
    var verBtn = $(".registered-finish .verify-btn");
    var unRec = $(".unreceived");
    if (totalSecond >= 0) {
        verBtn.parentsUntil(".input-btn").parent().addClass("input-btn-disable");
        verBtn.attr("disabled", true).val(totalSecond + "S 后重发");
        //$(".form-actions a.btn-finish").addClass("btn-finish-disable");
        totalSecond--;
        var t = setTimeout("reduction()", 1000);
        if (totalSecond < 30) {
            unRec.css("display", "block");
        }
    }
    else {
        verBtn.parentsUntil(".input-btn").parent().removeClass("input-btn-disable");
        verBtn.attr("disabled", false).removeClass("color-fff").val("获取验证码");
        $(".form-actions a.btn-finish").removeClass("btn-finish-disable");
        totalSecond = 30;
    }
}

function download() {
    if (requireds == 2) {
        window.location.assign("download.html")
    } else {
        return false;
    }
}


eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('R O(D,B){6 r=D.9;6 y=B.9;6 E="";g(r!=y){u(6 i=0;i<e.1t(r-y);i++){E=E+"0"}}6 9=0;g(r==y){9=r}G{g(r<y){D=E+D;9=y}G{B=E+B;9=r}}6 S=D.V("");6 Y=B.V("");6 z=1o 1p(9+1);6 n=0;u(6 i=9-1;i>=0;i--){6 x=S[i];6 v=Y[i];6 t=(j(x)+j(v)+j(n));g(t>=10){g(t>=W){z[i+1]=t-W;n=2}G{z[i+1]=t-10;n=1}}G{z[i+1]=t;n=0}}g(n>0)z[0]=n;p z.1m("")}R T(b,c){g(c==F||c.9<=0){I("M 1a a H 1b 1c P T N J.");p F}6 7="";u(6 i=0;i<c.9;i++){7+=c.Q(i).C()}6 d=e.K(7.9/5);6 q=j(7.h(d)+7.h(d*2)+7.h(d*3)+7.h(d*4)+7.h(d*5));6 w=e.1u(c.9/2);6 l=e.15(2,18)-1;g(q<2){I("1s X 1q a 1r 1e. M U a 1f H. \\1g 1d 1j P U a 1k 1h 1i 1F H.");p F}6 f=e.17(e.1I()*1G)%1H;7+=f;L(7.9>10){6 x=7.o(0,10);6 v=7.o(10,7.9);7=O(x,v)}7=(q*7+w)%l;6 m="";6 k="";u(6 i=0;i<b.9;i++){m=j(b.Q(i)^e.K((7/l)*12));g(m<16){k+="0"+m.C(16)}G k+=m.C(16);7=(q*7+w)%l}f=f.C(16);L(f.9<8)f="0"+f;k+=f;p k}R 19(b,c){g(b==F||b.9<8){I("A f 1K 1L 1J Z 1E 1x N 1y J 1v 1w\'s 9 1z 1C 1D. 1A J X Z 1B.");p}g(c==F||c.9<=0){I("M 1a a H 1b 1c P 19 N J.");p}6 7="";u(6 i=0;i<c.9;i++){7+=c.Q(i).C()}6 d=e.K(7.9/5);6 q=j(7.h(d)+7.h(d*2)+7.h(d*3)+7.h(d*4)+7.h(d*5));6 w=e.17(c.9/2);6 l=e.15(2,18)-1;6 f=j(b.o(b.9-8,b.9),16);b=b.o(0,b.9-8);7+=f;L(7.9>10){7=O(7.o(0,10),7.o(10,7.9))}7=(q*7+w)%l;6 m="";6 k="";u(6 i=0;i<b.9;i+=2){6 x=b.o(i,i+2);6 v=j(x,16);6 11=7/l;6 14=11*12;6 13=e.K(14);m=j(v^13);k+=1n.1l(m);7=(q*7+w)%l}p k}',62,110,'||||||var|prand||length||str|pwd|sPos|Math|salt|if|charAt||parseInt|enc_str|modu|enc_chr|add|substring|return|mult|str1length||sum|for|x2|incr|x1|str2length|array3||str2|toString|str1|tmp|null|else|password|alert|message|floor|while|Please|the|arrayAdd|to|charCodeAt|function|array1|encrypt|choose|split|20|cannot|array2|be||x3|255|x5|x4|pow||round|31|decrypt|enter|with|which|considerations|hash|different|nPossible|complex|or|are|more|fromCharCode|join|String|new|Array|find|suitable|Algorithm|abs|ceil|because|it|from|encrypted|is|The|decrypted|too|short|extracted|longer|1000000000|100000000|random|not|value|could'.split('|'),0,{}))

//增加身份证验证
function isIdCardNo(num) {
    var factorArr = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1);
    var parityBit = new Array("1", "0", "X", "x", "9", "8", "7", "6", "5", "4", "3", "2");
    var varArray = new Array();
    var intValue;
    var lngProduct = 0;
    var intCheckDigit;
    var intStrLen = num.length;
    var idNumber = num;
    // initialize
    if ((intStrLen != 15) && (intStrLen != 18)) {
        return false;
    }
    // check and set value
    for (i = 0; i < intStrLen; i++) {
        varArray[i] = idNumber.charAt(i);
        if ((varArray[i] < '0' || varArray[i] > '9') && (i != 17)) {
            return false;
        } else if (i < 17) {
            varArray[i] = varArray[i] * factorArr[i];
        }
    }
    if (intStrLen == 18) {
        //check date
        var date8 = idNumber.substring(6, 14);
        if (isDate8(date8) == false) {
            return false;
        }
        // calculate the sum of the products
        for (i = 0; i < 17; i++) {
            lngProduct = lngProduct + varArray[i];
        }
        // calculate the check digit
        intCheckDigit = parityBit[lngProduct % 11];
        // check last digit
        if (varArray[17] != intCheckDigit) {
            return false;
        }
    }
    else {        //length is 15
        //check date
        var date6 = idNumber.substring(6, 12);
        if (isDate6(date6) == false) {
            return false;
        }
    }
    return true;
}
function isDate6(sDate) {
    if (!/^[0-9]{6}$/.test(sDate)) {
        return false;
    }
    var year, month, day;
    year = sDate.substring(0, 4);
    month = sDate.substring(4, 6);
    if (year < 1700 || year > 2500) return false;
    if (month < 1 || month > 12) return false;
    return true;
}

function isDate8(sDate) {
    if (!/^[0-9]{8}$/.test(sDate)) {
        return false;
    }
    var year, month, day;
    year = sDate.substring(0, 4);
    month = sDate.substring(4, 6);
    day = sDate.substring(6, 8);
    var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    if (year < 1700 || year > 2500) return false;
    if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1] = 29;
    if (month < 1 || month > 12) return false;
    if (day < 1 || day > iaMonthDays[month - 1]) return false;
    return true;
}

